<?php
class ActlotteryModel extends Model {
	//自动验证文章内容
	protected $_validate=array(
		array('lang',       'require', '{%cfg_cont_require}'),
		array('title',      'require', '{%cfg_tiele_require}!'),
		array('allowa_num', 'require', '{%cfg_allnum_require}'),
		array('single_num', 'require', '{%cfg_single_num_require}'),
		array('detail_dui', 'require', '{%cfg_detail_dui_require}'),
		array('time_start', 'require', '{%cfg_time_start_require}'),
		array('time_end',   'require', '{%cfg_time_end_require}'),
	);
	
	//自动填充内容  addtime
	protected $_auto   =   array(
		array('addtime','time',1,'function'),//add添加的时候自动填充
	);
	
	
	//ajax获取当前活动的奖品总中奖概率
	public function prizeProbability($actid,$id){
		
		$model = M("ActlotteryPrize");
		
		$map['actid'] = $actid;
		$map['id']    = array('neq',$id);
		$data = $model->where($map)->sum("prize_probability");
		return $data;
	}
	
	/**
	 * 获取奖品详情
	 */
	public function getPrizeDetail($id){
		
		$model = M("ActlotteryPrize");
		
		$data = $model->find($id);
		return $data;
	}
	
	/**
	 * 获取活动详情
	 */
	public function getLotteryDetail($id){
		$data = $this->find($id);
		return $data;
	}
}
?>